package com.ruoyi.base.service.impl;

import java.util.List;
import java.util.UUID;

import com.ruoyi.base.domain.BusWaterSegment;
import com.ruoyi.base.mapper.BusWaterSegmentMapper;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.pwk.domain.BusPwkRhoutfall;
import com.ruoyi.pwk.mapper.BusPwkRhoutfallMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.base.mapper.BusWaterSegmentorrhoutfallMapper;
import com.ruoyi.base.domain.BusWaterSegmentorrhoutfall;
import com.ruoyi.base.service.IBusWaterSegmentorrhoutfallService;

/**
 * 断面和入河排口关联关系 （在用）Service业务层处理
 * 
 * @author maliang
 * @date 2025-07-27
 */
@Service
public class BusWaterSegmentorrhoutfallServiceImpl implements IBusWaterSegmentorrhoutfallService 
{
    @Autowired
    private BusWaterSegmentorrhoutfallMapper busWaterSegmentorrhoutfallMapper;
    @Autowired
    private BusWaterSegmentMapper busWaterSegmentMapper;
    @Autowired
    private BusPwkRhoutfallMapper busPwkRhoutfallMapper;

    /**
     * 查询断面和入河排口关联关系 （在用）
     * 
     * @param id 断面和入河排口关联关系 （在用）主键
     * @return 断面和入河排口关联关系 （在用）
     */
    @Override
    public BusWaterSegmentorrhoutfall selectBusWaterSegmentorrhoutfallById(String id)
    {
        BusWaterSegmentorrhoutfall waterSegmentorrhoutfall = busWaterSegmentorrhoutfallMapper.selectBusWaterSegmentorrhoutfallById(id);
        if(waterSegmentorrhoutfall != null && StringUtils.isNotEmpty(waterSegmentorrhoutfall.getSegmentid())){
            BusWaterSegment busWaterSegment = busWaterSegmentMapper.selectBusWaterSegmentByID(waterSegmentorrhoutfall.getSegmentid());
            waterSegmentorrhoutfall.setWaterSegment(busWaterSegment);
        }
        if(waterSegmentorrhoutfall != null && StringUtils.isNotEmpty(waterSegmentorrhoutfall.getRhoutfallid())){
            BusPwkRhoutfall busPwkRhoutfall = busPwkRhoutfallMapper.selectBusPwkRhoutfallById(waterSegmentorrhoutfall.getRhoutfallid());
            waterSegmentorrhoutfall.setPwkRhoutfall(busPwkRhoutfall);
        }
        return waterSegmentorrhoutfall;
    }

    /**
     * 查询断面和入河排口关联关系 （在用）列表
     * 
     * @param busWaterSegmentorrhoutfall 断面和入河排口关联关系 （在用）
     * @return 断面和入河排口关联关系 （在用）
     */
    @Override
    public List<BusWaterSegmentorrhoutfall> selectBusWaterSegmentorrhoutfallList(BusWaterSegmentorrhoutfall busWaterSegmentorrhoutfall)
    {
        return busWaterSegmentorrhoutfallMapper.selectBusWaterSegmentorrhoutfallList(busWaterSegmentorrhoutfall);
    }

    /**
     * 新增断面和入河排口关联关系 （在用）
     * 
     * @param busWaterSegmentorrhoutfall 断面和入河排口关联关系 （在用）
     * @return 结果
     */
    @Override
    public int insertBusWaterSegmentorrhoutfall(BusWaterSegmentorrhoutfall busWaterSegmentorrhoutfall)
    {
        busWaterSegmentorrhoutfall.setId(UUID.randomUUID().toString());
        return busWaterSegmentorrhoutfallMapper.insertBusWaterSegmentorrhoutfall(busWaterSegmentorrhoutfall);
    }

    /**
     * 修改断面和入河排口关联关系 （在用）
     * 
     * @param busWaterSegmentorrhoutfall 断面和入河排口关联关系 （在用）
     * @return 结果
     */
    @Override
    public int updateBusWaterSegmentorrhoutfall(BusWaterSegmentorrhoutfall busWaterSegmentorrhoutfall)
    {
        return busWaterSegmentorrhoutfallMapper.updateBusWaterSegmentorrhoutfall(busWaterSegmentorrhoutfall);
    }

    /**
     * 批量删除断面和入河排口关联关系 （在用）
     * 
     * @param ids 需要删除的断面和入河排口关联关系 （在用）主键
     * @return 结果
     */
    @Override
    public int deleteBusWaterSegmentorrhoutfallByIds(String[] ids)
    {
        return busWaterSegmentorrhoutfallMapper.deleteBusWaterSegmentorrhoutfallByIds(ids);
    }

    /**
     * 删除断面和入河排口关联关系 （在用）信息
     * 
     * @param id 断面和入河排口关联关系 （在用）主键
     * @return 结果
     */
    @Override
    public int deleteBusWaterSegmentorrhoutfallById(String id)
    {
        return busWaterSegmentorrhoutfallMapper.deleteBusWaterSegmentorrhoutfallById(id);
    }
}
